/*
 * Copyright 2008 LIN CHUNGYI.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package xmarsh.foo.zippost.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.VerticalPanel;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class ZipPostApp implements EntryPoint {

	public void onModuleLoad() {
		
		VerticalPanel vp = new VerticalPanel();
		final Label label = new Label();
		
		final ZipCodeClient zipClient = new ZipCodeClient(3,2);
		
		zipClient.loadData(new ChangeHandler() {	
			@Override
			public void onChange(ChangeEvent event) {
				label.setText(zipClient.getCityName() + "/"+zipClient.getZoneName() +" Zip Code : " + zipClient.getPostCode());							
			}
		});
				
		vp.add(zipClient.getCityListBox());
		vp.add(zipClient.getZoneListBox());
		vp.add(label);
		
		vp.add(new HTML("GET Name by cityId 2 and zoneID 7"));		
		final Label label2 = new Label();
		vp.add(label2);
		
		zipClient.fillLabelById(2, 7, label2);		
		RootPanel.get("content").add(vp);
	}
}
